export const global = {
	linkJump({url,callback,}) {
		if (!url) {
			return
		}
		let newUrl = url
		// 过滤首位的 /
		if (url[0] === '/') {
			newUrl = url.substring(1)
		}
		const pathname = newUrl.split('?')[0]
		const tabBarUrl = [
			'pages/index/index', 'pages/member/member', 'pages/shop/index', 'pages/service/index', 'pages/finds/index',
			// 'pages/goods/goodsList/goodsList', 'pages/scene/sceneList/sceneList',
			// 'pages/brand/brandList/brandList', 'pages/article/articleList/articleList', 'pages/user/user',
			// 'pages/login/login'
		] /* Tab页中的路径，请根据自己项目实际情况进行修改 */
		// 需要登录的页面
		const loginUrl = [
			'pages/index/index', 'pages/member/member', 'pages/shop/index', 'pages/service/index', 'pages/finds/index',
			// 'pages/goods/goodsList/goodsList', 'pages/scene/sceneList/sceneList',
			// 'pages/brand/brandList/brandList', 'pages/article/articleList/articleList', 'pages/user/user',
			// 'pages/login/login'
		]
		const page = getCurrentPages()
		// console.log(page,'战队')
		// 如果是Tab中的链接，直接跳转
		// if (tabBarUrl.includes(pathname)) {
		// 	uni.switchTab({
		// 		url: pathname,
		// 		success: () => {
		// 			callback && callback()
		// 		}
		// 	})
		// 	return
		// }
		// 如果是login中的链接，需要判断
			// if (loginUrl.includes(pathname)) {
			// 	return false
			// }
		if (page.length > 7) {
			if(tabBarUrl.includes(pathname)){
				
			}
			uni.reLaunch({
				url: url,
				success: () => {
					callback && callback()
				}
			})
			// uni.switchTab({
			// 	url: pathname,
			// 	success: () => {
			// 		callback && callback()
			// 	}
			// })
		} else {
	
			// 否则就直接跳转
			uni.navigateTo({
				url: url,
				success: () => {
					callback && callback()
				}
			})
		}
	},
	// 防止处理多次点击
	noMultipleClicks(methods, info) {
		// methods是点击后需要执行的函数， info是函数需要传的参数
		let that = this;
		if (that.noClick) {
			// 第一次点击
			that.noClick = false;
			if ((info && info !== '') || info == 0) {
				// info是执行函数需要传的参数
				methods(info);
			} else {
				methods();
			}
			setTimeout(() => {
				that.noClick = true;
			}, 3000)
		} else {
			//  这里是重复点击的判断
			uni.showToast({
				title: '点击过快，请稍后再试',
				icon: "none"
			})
		}
	}
}
